<html>
<head>
    <title>权限信息更新</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/stylesheets/upload.css">
    <script src="/layui/layui.js"></script>
    <script src="/layui/jquery.min.js"></script>
</head>
<body>
<div class="main" style="width: 90%;margin: 15px auto">
    <form class="layui-form">
        <input type="hidden" name="id" value="<%= power.id %>">
        <div class="layui-form-item">
            <label class="layui-form-label" for="powerName">权限名</label>
            <div class="layui-input-block">
                <input type="text" id="powerName" name="powerName" lay-verify="required" value="<%= power.powerName %>"
                       class="layui-input" placeholder="请输入权限名">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="profile">介绍</label>
            <div class="layui-input-block">
                <textarea name="profile" id="profile" class="layui-textarea" cols="30"
                          rows="10"><%= power.profile %></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-filter="submit" lay-submit>提交</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    layui.use(['form'], function () {
        const form = layui.form;
        form.on("submit(submit)", function (data) {
            $.ajax({
                url: "/power/update",
                method: "post",
                data: data.field,
                dataType: "json",
                success(res) {
                    if (res.code === 200) {
                        layer.msg('操作成功！', {icon: 6}, function () {
                            //先得到当前iframe层的索引
                            const index = parent.layer.getFrameIndex(window.name);
                            /*关闭当前弹窗*/
                            parent.layer.close(index);
                            /*刷新list页面的表格*/
                            parent.table.reload('dataTable')
                        })
                    } else {
                        layer.alert(res.msg, {icon: 5});
                    }
                }
            });
            return false;
        })
    })
</script>
</html>
